//
//  AnswerWoVC.m
//  dingdang
//
//  Created by 阮 沧晖 on 15/8/9.
//  Copyright (c) 2015年 阮 沧晖. All rights reserved.
//

#import "AnswerWoVC.h"
#import "DDNetWorkAPIClient.h"
#import "DDQuestionAnswerList.h"
#import "DDTopic.h"
#import "UIImageView+WebCache.h"

#import "SKSTableViewCell.h"

#define KEY_IMAGE @"IMAGE"
#define KEY_LABEL @"LABEL"
#define KEY_OPTION @"OPTION"
#define KEY_FILL @"FILL"
#define KEY_ANSWER_IMAGE @"ANSWER_IMAEG"
#define KEY_ANSWER_AUDIO @"ANSWER_AUDIO"

#define FILED_BODY_IMAGE @"IMAGE"
#define FILED_BODY_TEXT @"TEXT"

#define TOPIC_TYPE_FILL @"填空题"

@interface AnswerWoVC ()


@property (nonatomic,strong)NSMutableArray *datas;
@property (nonatomic,strong)DDQuestionAnswerListCell *questionAnswer;
@end

@implementation AnswerWoVC

- (void)viewDidLoad {
    NSLog(@"进入到---------->AnswerWoVC");
    
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    [self createUI];
    [self createData];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
    
}

- (void)createUI
{
    self.view.backgroundColor = RGB(245, 245, 245);
    self.automaticallyAdjustsScrollViewInsets = NO;
    self.navigationController.navigationBarHidden = YES;
    //自定义TAB BAR UI
    [self addNavigatorTitle:NSLocalizedString(@"回答我的", nil) parent:self.view];
    self.barViewControl.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"top_Background"]];
    [self AddLeftBtnAction:nil normal:@"top_返回" selected:@"top_返回" action:^{
        //[self dismissViewControllerAnimated:YES completion:nil];
        [self.navigationController popViewControllerAnimated:YES];
    }];
    
    
    
//    self.view.backgroundColor = [UIColor whiteColor];
//    self.tableView = [[SKSTableView alloc] initWithFrame:CGRectMake(0, 64, self.view.bounds.size.width, self.view.bounds.size.height-64) style:UITableViewStyleGrouped];
//    [self.view addSubview:self.tableView];
//    [self.tableView setSKSTableViewDelegate:self];
}

- (void)createData
{

    __weak AnswerWoVC *weakSelf = self;
    DDNetWorkAPIClient *network = [[DDNetWorkAPIClient alloc] init];
    [network mainQuestionAnswerList:@{@"topicId":_pushDB.topicId,@"qid":_pushDB.qid} completionBlock:^(BOOL isSuccess, NSString *message, NSString *status, id object) {
        
        DDQuestionAnswerList *mylist = (DDQuestionAnswerList*)object;
        NSArray *my = mylist.list;
        NSMutableArray *list = [NSMutableArray arrayWithArray:my];
        if (my.count > 0) {
            DDQuestionAnswerListCell *cell = my[0];
            _questionAnswer = my[0];
            [network mainQuestionReplyList:@{@"answerId":cell.id} completionBlock:^(BOOL isSuccess, NSString *message, NSString *status, id object) {
                
                DDQuestionAnswerReply *reply = (DDQuestionAnswerReply *)object;
                [list addObjectsFromArray:reply.list];
                
                NSMutableArray *secondArray = [NSMutableArray array];
                [secondArray addObject:list];
                [weakSelf.datas addObject:secondArray];
                [weakSelf.tableView reloadData];
            }];
        }
    }];
    
}



//#pragma mark -UITableDelegate
//- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
//{
//    id obj = self.datas[section];
//    if ([obj isKindOfClass:[NSArray class]]) {
//        return ((NSArray *)obj).count;
//    }
//    return 1;
//    //return [self.datas[section] count];;
//}
//-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
//{
//    return _datas.count;
//}
//
//- (NSInteger)tableView:(SKSTableView *)tableView numberOfSubRowsAtIndexPath:(NSIndexPath *)indexPath
//{
//    id obj = self.datas[indexPath.section];
//    if ([obj isKindOfClass:[NSArray class]]) {
//        return [self.datas[indexPath.section][indexPath.row] count] - 1;
//    }
//    return 0;
//}
//
//- (CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
//{
//    int height = 130;
//    if (indexPath.section == 0) {
//        
//        height = 90;
//        NSDictionary *dict = _datas[indexPath.section];
//        NSArray *images = [dict objectForKey:KEY_IMAGE];
//        NSArray *options = [dict objectForKey:KEY_OPTION];
//        NSArray *fills = [dict objectForKey:KEY_FILL];
//        if (_title) {
//            height += [self autoLabelString:self.tableView string:_title].height;
//        }
//        
//        if (images.count > 0) {
//            NSArray *array = [dict objectForKey:KEY_IMAGE];
//            height += 300 * array.count + 10;
//        }
//        if (options.count > 0)
//        {
//            NSArray *array = [dict objectForKey:KEY_OPTION];
//            height += 38*array.count+70;
//        }
//        if (fills.count > 0)
//        {
//            height += 200;
//        }
//    }else{
//        height = 80;
//        id obj = self.datas[indexPath.section];
//        if ([obj isKindOfClass:[NSArray class]]) {
//            
//            id  object = self.datas[indexPath.section][0][indexPath.row];
//            if (indexPath.row==0) {
//                DDQuestionAnswerListCell *answerListCell = object;
//                height += [self autoLabelString:self.tableView string:answerListCell.answer].height;
//                
//                NSArray *explanations = answerListCell.explanation;
//                for (DDQuestionAnswerExplanation *explanation in explanations) {
//                    if ([explanation.type isEqualToString:@"TEXT"]) {
//                        height += [self autoLabelString:self.tableView string:explanation.text].height;
//                    }
//                    else if([explanation.type isEqualToString:@"IMAGE"])
//                    {
//                        height += 300;
//                    }
//                }
//            }else{
//                DDQuestionAnswerReplyCell *reply = object;
//                for (DDQuestionAnswerReplyContent *content in reply.content) {
//                    if ([content.type isEqualToString:@"TEXT"]) {
//                        height += [self autoLabelString:self.tableView string:content.text].height;
//                    }
//                    else if([content.type isEqualToString:@"IMAGE"])
//                    {
//                        height += 300;
//                    }
//                }
//            }
//            
//            
//            
//            
//            
//            
//        }else{
//            
//            DDQuestionAnswerListCell *answerListCell = _datas[indexPath.section];
//            id obj = self.datas[indexPath.section];
//            if ([obj isKindOfClass:[NSArray class]]) {
//                answerListCell = self.datas[indexPath.section][0][0];
//                
//            }else{
//                answerListCell = _datas[indexPath.section];
//            }
//            //DDQuestionAnswerListCell *answerListCell = _datas[indexPath.section];
//            height += [self autoLabelString:self.tableView string:answerListCell.answer].height;
//            
//            NSArray *explanations = answerListCell.explanation;
//            for (DDQuestionAnswerExplanation *explanation in explanations) {
//                if ([explanation.type isEqualToString:@"TEXT"]) {
//                    height += [self autoLabelString:self.tableView string:explanation.text].height;
//                }
//                else if([explanation.type isEqualToString:@"IMAGE"])
//                {
//                    height += 300;
//                }
//            }
//        }
//    }
//    return height;
//}
//- (CGSize)autoImage:(UIImage *)image
//{
//    float w = image.size.width/2;
//    float h = image.size.height/2;
//    if (w > self.tableView.frame.size.width - 10) {
//        //tw/th = w/h = c;
//        float c = (self.tableView.frame.size.width - 10)/w;
//        float tw = self.tableView.frame.size.width - 10;
//        float th = h*c;
//        
//        return CGSizeMake(tw, th);
//    }else{
//        return CGSizeMake(w, h);
//    }
//    
//}
//
//- (CGSize)autoLabelString:(UIView *)view string:(NSString *)s
//{
//    UIFont *font = [UIFont fontWithName:@"Arial" size:17];
//    //设置一个行高上限
//    CGSize size = CGSizeMake(view.frame.size.width - 10,2000);
//    //计算实际frame大小，并将label的frame变成实际大小
//    CGSize labelsize = [s sizeWithFont:font constrainedToSize:size lineBreakMode:UILineBreakModeWordWrap];
//    return labelsize;
//}
//
//- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
//{
//    //    static NSString *identifier = @"UITableViewCell";
//    //    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
//    //    if (cell == nil) {
//    //        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
//    //        cell.selectionStyle = UITableViewCellSelectionStyleNone;
//    //
//    //    }
//    static NSString *CellIdentifier = @"SKSTableViewCell";
//    
//    SKSTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
//    
//    if (!cell)
//        cell = [[SKSTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
//    
//    
//    for (UIView *view in cell.contentView.subviews) {
//        [view removeFromSuperview];
//    }
//    
//    if (indexPath.section == 0) {
//        DDQuestionAnswerListCell *topicModel = _questionAnswer;
//        DDQuestionAnswerQuestion *question = topicModel.question;
//        float start_X = 5;
//        float start_Y = 5;
//        
//        
//        UIImageView *header_imageView = [[UIImageView alloc] initWithFrame:CGRectMake(start_X, start_Y, 50, 50)];
//        //header_imageView.image = [UIImage imageNamed:@"user_header"];
//        [header_imageView sd_setImageWithURL:[NSURL URLWithString:topicModel.userAvatarUrl] placeholderImage:[UIImage imageNamed:@"首页列表头像-通用"]options:SDWebImageRefreshCached];
//        header_imageView.layer.cornerRadius = 25.0;
//        header_imageView.layer.masksToBounds = YES;
//        [cell.contentView addSubview:header_imageView];
//        
//        UILabel *name_label = [[UILabel alloc] initWithFrame:CGRectMake([self xPostiong:header_imageView sp:10],header_imageView.frame.origin.y+5 , 200, 24)];
//        name_label.text = topicModel.userName;
//        name_label.textColor = RGB(124,203,203);
//        [cell.contentView addSubview:name_label];
//        
//        UILabel *time_label = [[UILabel alloc] initWithFrame:CGRectMake(name_label.frame.origin.x,[self yPostiong:name_label sp:5] , 200, 16)];
//        time_label.text = [self convertTime:topicModel.answerTime];//@"1天前";
//        time_label.font = [UIFont fontWithName:@"Arial" size:12.0f];
//        time_label.textColor = [UIColor lightGrayColor];
//        [cell.contentView addSubview:time_label];
//        
//        
//        
//        UIImageView *gold_imageview = [[UIImageView alloc] initWithFrame:CGRectMake(tableView.frame.size.width - 80, name_label.frame.origin.y+3, 15, 15)];
//        gold_imageview.image = [UIImage imageNamed:@"icon_gold"];
//        [cell.contentView addSubview:gold_imageview];
//        
//        UILabel *gold_label = [[UILabel alloc] initWithFrame:CGRectMake([self xPostiong:gold_imageview sp:4],  name_label.frame.origin.y+3, 70, 16)];
//        gold_label.text = topicModel.reward;
//        gold_label.font = [UIFont fontWithName:@"Arial" size:12.0f];
//        gold_label.textColor = [UIColor orangeColor];
//        [cell.contentView addSubview:gold_label];
//        
//        if (_typeIndex == 0 || _typeIndex == 2) {
//            gold_imageview.hidden = YES;
//            gold_label.hidden = YES;
//        }
//        
//        UIButton *typeButton = [UIButton buttonWithType:UIButtonTypeCustom];
//        typeButton.frame = CGRectMake([self xPostiong:gold_imageview sp:10], gold_imageview.frame.origin.y, 50, 18);
//        [typeButton setBackgroundImage:[UIImage imageNamed:@"icon_tag"] forState:UIControlStateNormal];
//        
//        NSString *typeName = questions.count > 0 ?((DDTopicQuestion *)questions[0]).typeName : @"";
//        [typeButton setTitle:typeName forState:UIControlStateNormal];
//        
//        typeButton.titleLabel.font = [UIFont fontWithName:@"Arial" size:10.0];
//        [typeButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
//        ///[typeButton setTitleEdgeInsets:UIEdgeInsetsMake(0, -20, 0, 0)];
//        //[typeButton setImageEdgeInsets:UIEdgeInsetsMake(0, 0, 0, 0)];
//        [cell.contentView addSubview:typeButton];
//        
//        UILabel *content_label = [[UILabel alloc] initWithFrame:CGRectMake(header_imageView.frame.origin.x,[self yPostiong:header_imageView sp:10] , tableView.frame.size.width -10, [self autoLabelString:self.tableView string:_title].height)];
//        content_label.numberOfLines = 0;
//        content_label.text = _title;
//        [cell.contentView addSubview:content_label];
//        
//        
//        int startHeight = [self yPostiong:content_label sp:10];
//        
//        NSDictionary *dict = _datas[indexPath.section];
//        NSArray *images = [dict objectForKey:KEY_IMAGE];
//        NSArray *options = [dict objectForKey:KEY_OPTION];
//        NSArray *fills = [dict objectForKey:KEY_FILL];
//        
//        if (images.count) {
//            NSArray *array = images;
//            _imageArray = images;
//            for (int i = 0 ; i < array.count ; i++)
//            {
//                NSString *url = array[i];
//                NSRange range = [url rangeOfString:@"http://"];//判断字符串是否包含
//                if (range.length >0)//包含
//                {
//                }else{
//                    continue;
//                }
//                
//                startHeight = startHeight + (300*i);
//                
//                UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(10, startHeight , tableView.frame.size.width - 20, 300)];
//                [imageView sd_setImageWithURL:[NSURL URLWithString:array[i]] placeholderImage:[UIImage imageNamed:@"首页-答疑-客观题-单选习题拍照图-通用"]options:SDWebImageRefreshCached];
//                [cell.contentView addSubview:imageView];
//                //imageView.contentMode =  UIViewContentModeScaleAspectFill;
//                UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
//                button.frame = imageView.frame;
//                [button addTarget:self action:@selector(handleSingleTapImage) forControlEvents:UIControlEventTouchUpInside];
//                
//                [cell.contentView addSubview:button];
//            }
//            startHeight += 300;
//        }
//        
//        
//        if (options.count > 0)
//        {
//            NSArray *array = options;
//            UILabel *typeLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, startHeight, tableView.frame.size.width, 32)];
//            typeLabel.text = [NSString stringWithFormat:@"(%@)", _questionType];
//            [cell.contentView addSubview:typeLabel];
//            for (int i = 0; i < array.count; i++) {
//                DDTopicQuestionOption *option = array[i];
//                UIButton *optionButton = [UIButton buttonWithType:UIButtonTypeCustom];
//                optionButton.frame = CGRectMake(10, [self yPostiong:typeLabel sp:10 + (44*i)], 38, 38);
//                [optionButton setTitle:option.label forState:UIControlStateNormal];
//                
//                if (_showAnswer && [_question.answer isEqualToString:option.label]) {
//                    [optionButton setBackgroundImage:[UIImage imageNamed:@"首页-答疑-客观题-圆点选中_09"] forState:UIControlStateNormal];
//                }else{
//                    
//                    [optionButton setBackgroundImage:[UIImage imageNamed:@"首页-答疑-客观题-选项bg灰"] forState:UIControlStateNormal];
//                    [optionButton setBackgroundImage:[UIImage imageNamed:@"首页-答疑-客观题-选项bg橙"] forState:UIControlStateSelected];
//                }
//                
//                [optionButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
//                optionButton.tag = i+1000;
//                //[optionButton addTarget:self action:@selector(optionSelect:) forControlEvents:UIControlEventTouchUpInside];
//                
//                
//                [cell.contentView addSubview:optionButton];
//                
//                DDTopicQuestionOptionContent *content = option.content[0];
//                if ([content.type isEqualToString:@"TEXT"])
//                {
//                    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake([self xPostiong:optionButton sp:10], optionButton.frame.origin.y+5, tableView.frame.size.width-100, 24)];
//                    label.text = content.text;
//                    label.textColor = [UIColor blackColor];
//                    [cell.contentView addSubview:label];
//                }
//                else if ([content.type isEqualToString:@"IMAGE"])
//                {
//                    UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake([self xPostiong:optionButton sp:10], optionButton.frame.origin.y+5, 32, 32)];
//                    [imageView sd_setImageWithURL:[NSURL URLWithString:content.url] placeholderImage:[UIImage imageNamed:@"个人中心-人数统计头像"]options:SDWebImageRefreshCached];
//                    [cell.contentView addSubview:imageView];
//                }
//                
//            }
//        }
//        
//        
//        if (fills.count > 0) {
//            UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(5, 5, self.tableView.frame.size.width-10, 24)];
//            titleLabel.text = _questionType;
//            
//            [cell.contentView addSubview:titleLabel];
//            
//            _fillTextView = [[UITextView alloc] initWithFrame:CGRectMake(5, [self yPostiong:titleLabel sp:5], self.tableView.frame.size.width-10, 150)];
//            _fillTextView.layer.borderWidth = 1.0;
//            _fillTextView.layer.borderColor = [UIColor lightGrayColor].CGColor;
//            _fillTextView.layer.cornerRadius = 10;
//            _fillTextView.delegate = self;
//            [cell.contentView addSubview:_fillTextView];
//        }
//    }
//    else//回答列表
//    {
//        DDQuestionAnswerListCell *questionCell = _datas[indexPath.section];
//        id obj = self.datas[indexPath.section];
//        if ([obj isKindOfClass:[NSArray class]]) {
//            questionCell = self.datas[indexPath.section][0][0];
//            if ([self.datas[indexPath.section][indexPath.row] count] - 1 > 0) {
//                cell.isExpandable = YES;
//            }
//        }else{
//            questionCell = _datas[indexPath.section];
//            cell.isExpandable = NO;
//        }
//        
//        float start_X = 5;
//        float start_Y = 5;
//        
//        
//        UIImageView *header_imageView = [[UIImageView alloc] initWithFrame:CGRectMake(start_X, start_Y, 50, 50)];
//        //header_imageView.image = [UIImage imageNamed:@"user_header"];
//        [header_imageView sd_setImageWithURL:[NSURL URLWithString:questionCell.userAvatarUrl] placeholderImage:[UIImage imageNamed:@"首页列表头像-通用"]options:SDWebImageRefreshCached];
//        header_imageView.layer.cornerRadius = 25.0;
//        header_imageView.layer.masksToBounds = YES;
//        [cell.contentView addSubview:header_imageView];
//        
//        UILabel *name_label = [[UILabel alloc] initWithFrame:CGRectMake([self xPostiong:header_imageView sp:10],header_imageView.frame.origin.y+5 , 200, 24)];
//        name_label.text = questionCell.userName;
//        name_label.textColor = RGB(124,203,203);
//        [cell.contentView addSubview:name_label];
//        
//        UILabel *time_label = [[UILabel alloc] initWithFrame:CGRectMake(name_label.frame.origin.x,[self yPostiong:name_label sp:5] , 200, 16)];
//        time_label.text = questionCell.answerTime;//@"1天前";
//        time_label.font = [UIFont fontWithName:@"Arial" size:12.0f];
//        time_label.textColor = [UIColor lightGrayColor];
//        [cell.contentView addSubview:time_label];
//        
//        
//        
//        
//        UILabel *content_label = [[UILabel alloc] initWithFrame:CGRectMake(header_imageView.frame.origin.x,[self yPostiong:header_imageView sp:10] , tableView.frame.size.width -10, [self autoLabelString:self.tableView string:questionCell.answer].height)];
//        content_label.numberOfLines = 0;
//        content_label.text = questionCell.answer;
//        [cell.contentView addSubview:content_label];
//        
//        
//        int anwerHeight = [self yPostiong:content_label sp:10] ;
//        NSArray *explanations = questionCell.explanation;
//        for (DDQuestionAnswerExplanation *explanation in explanations) {
//            if ([explanation.type isEqualToString:@"TEXT"]) {
//                UILabel *content_label = [[UILabel alloc] initWithFrame:CGRectMake(header_imageView.frame.origin.x,anwerHeight, tableView.frame.size.width -10, [self autoLabelString:self.tableView string:explanation.text].height)];
//                content_label.numberOfLines = 0;
//                content_label.text = explanation.text;
//                [cell.contentView addSubview:content_label];
//                anwerHeight+=[self autoLabelString:self.tableView string:explanation.text].height;
//            }else if([explanation.type isEqualToString:@"IMAGE"])
//            {
//                _answerImageArray = @[explanation.url];
//                
//                UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(10, anwerHeight , tableView.frame.size.width - 20, 300)];
//                [imageView sd_setImageWithURL:[NSURL URLWithString:explanation.url] placeholderImage:[UIImage imageNamed:@"首页-答疑-客观题-单选习题拍照图-通用"]options:SDWebImageRefreshCached];
//                [cell.contentView addSubview:imageView];
//                //imageView.contentMode =  UIViewContentModeScaleAspectFill;
//                UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
//                button.frame = imageView.frame;
//                [button addTarget:self action:@selector(handleAnswerSingleTapImage) forControlEvents:UIControlEventTouchUpInside];
//                [cell.contentView addSubview:button];
//                anwerHeight += 300;
//            }
//            
//        }
//    }
//    
//    
//    return cell;
//    
//}
//
//- (UITableViewCell *)tableView:(UITableView *)tableView cellForSubRowAtIndexPath:(NSIndexPath *)indexPath
//{
//    static NSString *CellIdentifier = @"UITableViewCell";
//    
//    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
//    
//    if (!cell)
//        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
//    
//    for (UIView *view in cell.contentView.subviews) {
//        [view removeFromSuperview];
//    }
//    
//    DDQuestionAnswerReplyCell * answerReply = self.datas[indexPath.section][indexPath.row][indexPath.subRow];
//    
//    float start_X = 5;
//    float start_Y = 5;
//    
//    
//    UIImageView *header_imageView = [[UIImageView alloc] initWithFrame:CGRectMake(start_X, start_Y, 50, 50)];
//    //header_imageView.image = [UIImage imageNamed:@"user_header"];
//    [header_imageView sd_setImageWithURL:[NSURL URLWithString:answerReply.userAvatarUrl] placeholderImage:[UIImage imageNamed:@"首页列表头像-通用"]options:SDWebImageRefreshCached];
//    header_imageView.layer.cornerRadius = 25.0;
//    header_imageView.layer.masksToBounds = YES;
//    [cell.contentView addSubview:header_imageView];
//    
//    UILabel *name_label = [[UILabel alloc] initWithFrame:CGRectMake([self xPostiong:header_imageView sp:10],header_imageView.frame.origin.y+5 , 200, 24)];
//    name_label.text = answerReply.userName;
//    name_label.textColor = RGB(124,203,203);
//    [cell.contentView addSubview:name_label];
//    
//    UILabel *time_label = [[UILabel alloc] initWithFrame:CGRectMake(name_label.frame.origin.x,[self yPostiong:name_label sp:5] , 200, 16)];
//    time_label.text = answerReply.createTime;//@"1天前";
//    time_label.font = [UIFont fontWithName:@"Arial" size:12.0f];
//    time_label.textColor = [UIColor lightGrayColor];
//    [cell.contentView addSubview:time_label];
//    
//    
//    NSArray *contents = answerReply.content;
//    int height = [self yPostiong:header_imageView sp:10];
//    for (DDQuestionAnswerReplyContent *content in contents) {
//        if ([content.type isEqualToString:@"TEXT"]) {
//            UILabel *content_label = [[UILabel alloc] initWithFrame:CGRectMake(header_imageView.frame.origin.x,height , tableView.frame.size.width -10, [self autoLabelString:self.tableView string:content.text].height)];
//            content_label.numberOfLines = 0;
//            content_label.text = content.text;
//            [cell.contentView addSubview:content_label];
//            height+=[self autoLabelString:self.tableView string:content.text].height;
//        }else if([content.type isEqualToString:@"IMAGE"])
//        {
//            _answerImageArray = @[content.url];
//            UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(10, height , tableView.frame.size.width - 20, 300)];
//            [imageView sd_setImageWithURL:[NSURL URLWithString:content.url] placeholderImage:[UIImage imageNamed:@"首页-答疑-客观题-单选习题拍照图-通用"]options:SDWebImageRefreshCached];
//            [cell.contentView addSubview:imageView];
//            //imageView.contentMode =  UIViewContentModeScaleAspectFill;
//            UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
//            button.frame = imageView.frame;
//            [button addTarget:self action:@selector(handleAnswerSingleTapImage) forControlEvents:UIControlEventTouchUpInside];
//            [cell.contentView addSubview:button];
//            
//            height += 300;
//        }
//    }
//    
//    
//    
//    return cell;
//}
//
//-(float) xPostiong:(UIView *)view sp:(float)sp
//{
//    return view.frame.size.width+view.frame.origin.x + sp;
//}
//
//-(float) yPostiong:(UIView *)view sp:(float)sp
//{
//    return view.frame.size.height+view.frame.origin.y + sp;
//}
//
//- (NSString *)convertTime:(NSString *)time
//{
//    if (!time || [@"" isEqualToString:time]) {
//        return @"";
//    }
//    
//    
//    NSDate *datenow = [NSDate date];//现在时间,你可以输出来看下是什么格式
//    NSString *timeSp = [NSString stringWithFormat:@"%ld", (long)[datenow timeIntervalSince1970]];
//    
//    long a =  [timeSp longLongValue] - time.longLongValue/1000;
//    
//    long day = a/(3600*24);
//    
//    if (day < 360 && day > 30) {
//        return [NSString stringWithFormat:@"%ld个月前",day/30];
//    }
//    else if (day >360){
//        return [NSString stringWithFormat:@"%ld年以前",day/360];
//    }
//    else if (day == 0)
//    {
//        long second = a/3600;
//        if (second > 0 && second < 24) {
//            return [NSString stringWithFormat:@"%ld小时前",second];
//        }else{
//            return [NSString stringWithFormat:@"%ld分钟前",a/60];
//        }
//        
//    }
//    else if (day > 1 && day < 6){
//        return [NSString stringWithFormat:@"%ld天前",day];
//    }else{
//        //实例化一个NSDateFormatter对象
//        NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
//        //设定时间格式,这里可以设置成自己需要的格式
//        [dateFormatter setDateFormat:@"yyyy-MM-dd"];
//        //用[NSDate date]可以获取系统当前时间
//        NSDate *d = [NSDate dateWithTimeIntervalSince1970:time.longLongValue/1000];
//        NSString *dateStr = [dateFormatter stringFromDate:d];
//        return dateStr;
//    }
//    return @"";
//}
//
//-(void)handleSingleTapImage
//{
//    _photos = [NSMutableArray array];
//    
//    for (int i = 0; i < _imageArray.count ; i++) {
//        NSString *url = _imageArray[i];
//        NSRange range = [url rangeOfString:@"http://"];//判断字符串是否包含
//        if (range.length >0)//包含
//        {
//            MWPhoto   *photo = [MWPhoto photoWithURL:[NSURL URLWithString:url]];
//            //photo.caption = _friendInfo.username;
//            [_photos addObject:photo];
//        }else{
//            continue;
//        }
//    }
//    
//    [[NSNotificationCenter defaultCenter]  postNotificationName:@"DisPlayImage" object:_photos];
//    
//}
//-(void)handleAnswerSingleTapImage
//{
//    _photos = [NSMutableArray array];
//    
//    for (int i = 0; i < _answerImageArray.count ; i++) {
//        NSString *url = _answerImageArray[i];
//        NSRange range = [url rangeOfString:@"http://"];//判断字符串是否包含
//        if (range.length >0)//包含
//        {
//            MWPhoto   *photo = [MWPhoto photoWithURL:[NSURL URLWithString:url]];
//            //photo.caption = _friendInfo.username;
//            [_photos addObject:photo];
//        }else{
//            continue;
//        }
//    }
//    
//    [[NSNotificationCenter defaultCenter]  postNotificationName:@"DisPlayImage" object:_photos];
//}
//- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
//    
//}



@end
